package com.p2p.front.facade.impl;
/**
 * 
 *//*
package com.p2p.user.facade.impl;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.p2p.base.model.Money;
import com.p2p.user.dal.model.LoanInfo;
import com.p2p.user.dal.model.LoanStatus;
import com.p2p.user.facade.LoanFacade;
import com.p2p.user.service.LoanInfoService;
import com.p2p.user.service.LoanStatusService;

*//**
 * @author ruiqi
 *
 *//*

public class LoanFacadeImpl implements LoanFacade{

	@Resource
	private LoanInfoService loanInfoService;
	
	@Resource
	private LoanStatusService loanStatusService;
	
	@Override
	public boolean addAmountForTender(Long lid,Money amount) {
		
		LoanStatus loanStatus = loanFacade.getAndLockById(lid);
		if(loanStatus==null){
			return result;
		}
		Money tenderAmount = loanStatus.addTenderAmount(amount);
		if(tenderAmount.getCent()==0L){
			return result;
		}
		return false;
		return false;
	}
	
	@Transactional(propagation=Propagation.MANDATORY)
	public LoanStatus getAndLockById(Long lid){
		LoanStatus loanStatus = loanStatusService.selectByIdForUpdate(lid);
		if(loanStatus==null){
			boolean create = createLoanStatus(lid);
			if(create){
				loanStatus = loanStatusService.selectByIdForUpdate(lid);
			}
		}
		return loanStatus;
	}
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED)
	public boolean createLoanStatus(Long lid){
		LoanInfo loanInfo = loanInfoService.getLoanInfoById(lid);
		if(loanInfo==null){
			return false;
		}
		
		int tenderStatus = loanInfo.checkStatusCanTender();
		
		if(tenderStatus==0){
			return false;
		}
		if(tenderStatus==2){
			loanInfoService.updateStatus(lid, 21);
		}
		LoanStatus newloanStatus = new LoanStatus();
		newloanStatus.setLoanId(loanInfo.getLid());
		newloanStatus.setAmount(loanInfo.getAmount());
		newloanStatus.setStatus(loanInfo.getStatus());
		try {
			loanStatusService.create(newloanStatus);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return true;
	}
	

}
*/